<template>
<button v-on:click="triggerEvent1">触发event1事件</button>
  <br>
<button v-on:click="clearAllEvent">解除所有事件</button>
  <br>
<button v-on:click="clearEvent1">解除event1事件</button>
</template>

<script>
import emitter from '../utils/event-bus.js'
export default {
  name: "User",
  setup(props,context){
    function triggerEvent1(){
      emitter.emit('event1',{name:'zhangsan',age:32})
    }
    function clearAllEvent(){
      emitter.all.clear()
    }
    function clearEvent1(){
      emitter.off('event1')
    }
    return{
      triggerEvent1,
      clearAllEvent,
      clearEvent1
    }
  }
}
</script>

<style scoped>

</style>